import { saveInitTophubOperate } from '@/services/api/api-tophub-operate';
import { SmileOutlined } from '@ant-design/icons';
import { ActionType, DrawerForm, ProFormInstance } from '@ant-design/pro-components';
import { useAccess } from '@umijs/max';
import { Button, Flex, Result, Spin } from 'antd';
import React, { useRef, useState } from 'react';
interface AddOperateCreateProps {
  onRefurbish: () => void;
}

const AddOperateCreate: React.FC<AddOperateCreateProps> = ({ onRefurbish }) => {
  const access = useAccess();

  const actionRef = useRef<ActionType>();

  const formRef = useRef<ProFormInstance>();

  const [loading, setLoading] = useState(false);
  const [queryLoading, setQueryLoading] = useState(false);

  const [saveInit, setSaveInitState] = useState<TophubOperateData.OperateSaveInit>();

  /**
   * 加载 选题计划详情
   * @param key
   */
  const loadSaveInitTophubRecord = async () => {
    setLoading(true);
    try {
      const response = await saveInitTophubOperate();
      const { code, data } = response;
      if (code === 0) {
        setSaveInitState(data);
        setLoading(false);
      }
    } catch (error) {}
  };

  return (
    <DrawerForm
      title="新建词条"
      trigger={<Button type="primary">新建</Button>}
      drawerProps={{
        maskClosable: false,
        destroyOnClose: true,
        width: 650,
      }}
      formRef={formRef}
      onOpenChange={async (visible) => {
        if (visible) {
          loadSaveInitTophubRecord();
        } else {
        }
      }}
      onValuesChange={(values) => {}}
      submitter={false}
      onFinish={async (values) => {
        console.log(values);
      }}
    >
      {loading ? (
        <Flex
          style={{
            marginTop: '50px',
          }}
          justify={'center'}
          align={'flex-start'}
        >
          <Spin />
        </Flex>
      ) : (
        <>
          <Result icon={<SmileOutlined />} title="正在开发！" />
          {/* <ProFormCascader
            label="来源"
            name="sources"
            placeholder="选择来源"
            rules={[
              {
                required: true,
                message: '选择来源!',
              },
            ]}
            fieldProps={{
              options: saveInit?.sources,
              showSearch: true,
              onChange: (value, selectOptions) => {
                let channel = selectOptions[0];
                setSelectChannelState(channel.label);

                if (channel.label == '微信') {
                  setRecordTypeState(1);
                } else if (
                  channel.label == '微博' ||
                  channel.label == '抖音' ||
                  channel.label == '今日头条'
                ) {
                  setRecordTypeState(2);
                }
              },
            }}
          />

          <ProFormText
            name="hotName"
            label="热点词条"
            hidden={recordType != 1}
            placeholder="请输入热点词条"
            rules={[{ required: true, message: '请输入热点词条' }]}
          />
          <ProFormTextArea
            name="link"
            label="热点链接"
            fieldProps={{
              allowClear: true,
              rows: 3,
              maxLength: 5000,
            }}
          />
          <ProFormSelect
            options={[
              {
                label: '全部',
                value: '',
              },
              {
                label: '全国',
                value: '0',
              },
              {
                label: '重庆',
                value: '1',
              },
            ]}
            name="recordIsCity"
            label="范围"
            rules={[{ required: true, message: '请选择类型' }]}
          />
          <ProFormDateTimePicker
            name="deadlineTime"
            required
            width="100%"
            label="上榜时间"
            fieldProps={{
              // minDate: dayjs(),
              format: 'YYYY-MM-DD HH:mm:ss',
            }}
          />
          <ProFormText
            name="datahubRecordName"
            label="标题"
            hidden={recordType != 2}
            placeholder="请输入标题"
            rules={[{ required: true, message: '请输入标题' }]}
          />

          <ProFormTextArea
            name="remarks"
            label="备注"
            placeholder="请输入"
            fieldProps={{
              rows: 3,
            }}
          />

          <FormItem
            name="recordAttachments"
            label={
              <span
                style={{
                  marginLeft: 11,
                }}
              >
                附件
              </span>
            }
          >
            <UploadDragger
              onPreview={(file) => {}}
              access={{
                isPicture: access.热搜热榜x配置x运营员,
                isVideo: access.热搜热榜x配置x运营员,
                isOffice: access.热搜热榜x配置x运营员,
                isOther: access.热搜热榜x配置x运营员,
              }}
              url="/tophub/attachment/save"
              maxCount={2}
            />
          </FormItem> */}
        </>
      )}
    </DrawerForm>
  );
};
export default AddOperateCreate;
